home *** CD-ROM | disk | FTP | other *** search
- Path: dawn.mmm.com!news
- From: kjhopps@mmm.com (Kevin J Hopps)
- Newsgroups: comp.lang.c++
- Subject: Re: On Exception handling.....from a newbie
- Date: 15 Jan 1996 14:50:25 GMT
- Organization: 3M - St. Paul, MN 55144-1000 US
- Message-ID: <4ddpjh$3au@dawn.mmm.com>
- References: <1996Jan15.013336.4730@sfov1.verifone.com>
- Reply-To: kjhopps@mmm.com
- X-Newsreader: TIN [version 1.2 PL2]
-
- khemani_p1@hnlv4.verifone.com wrote:
-
-
-
- > I want to know how do I retry a try block which has thrown a exception. Is
- > there some neat of doing this in C++ ?
-
- You can always put the try block inside a loop...
-
- > For eg.
-
- > try {
- > open file;
- > read the blocks;
- > ...
- > } catch (OpenFileException e)
- > {
- > retry (how?)
- > }
- > catch (ReadFileException e)
- > {
- > close file;
- > retry (?)
- > }
-
- How about this?
- bool retry = true;
- while (retry) {
- AutoFileCloser autoCloser;
- try {
- open file;
- autoCloser.manage(something); // give "handle" to autoCloser
- read the blocks;
- retry = false;
- } catch (OpenFileException e) {
- } catch (ReadFileException e) {
- }
- // autoCloser closes file here, if necessary
- }
-
- > Please send the reply to khemani_p1@verifone.com
-
- Unless you promise to post a summary, read your replies here. People
- read your article because it sounds interesting. They deserve to read
- the replies too.
- --
- Kevin J. Hopps e-mail: kjhopps@mmm.com
- 3M Company phone: (612) 737-4643
- 3M Center, Bldg. 235-2D-57 fax: (612) 737-2700
- St. Paul, MN 55144-1000 Opinions are my own. I don't speak for 3M.
- But 3M speaks for me -- I did not write the following line:
-
- Opinions expressed herein are my own and may not represent those of 3M.
-